package com.youngjun.user.controller;

import com.youngjun.common.mybatis.web.BaseController;
import com.youngjun.common.mybatis.web.Response;
import com.youngjun.user.api.IDocumentRestApi;
import com.youngjun.user.pojo.vo.DocumentVO;
import com.youngjun.user.service.DocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/document")
public class DocumentController implements IDocumentRestApi,BaseController {

    @Autowired
    DocumentService documentService;

    @Override
    public Response<DocumentVO> upload(MultipartFile file) {
        DocumentVO data = documentService.upload(file);
        return new Response<>(data);
    }

    @Override
    public void download(@RequestParam String id) {
        documentService.download(id,getResponse());
    }

}